home *** CD-ROM | disk | FTP | other *** search
/ Internet.Works 40 / Issue 40.iso / pc / PCSoftware / HTML Tool 3.5 / htmltool.exe / _SETUP.1 / Faded Text.scp < prev    next >
Encoding:
Text File  |  2000-06-24  |  3.5 KB  |  132 lines

  1. <HTMLtool>Example of color-fade</HTMLtool>
  2.  
  3. <script language="JavaScript">
  4. <!-- Hide the script from old browsers --
  5. function MakeArray(n){   
  6.     this.length=n;   
  7.     for(var i=1; i<=n; i++) this[i]=i-1;   
  8.         return this
  9.     }
  10.     hex=new MakeArray(16);
  11.     hex[11]="A"; 
  12.     hex[12]="B"; 
  13.     hex[13]="C"; 
  14.     hex[14]="D"; 
  15.     hex[15]="E"; 
  16.     hex[16]="F";
  17.  
  18. function ToHex(x){              
  19.     // Changes a int to hex (in the range 0 to 255)   
  20.     var high=x/16;   
  21.     var s=high+"";               
  22.     //1   
  23.     s=s.substring(0,2);          
  24.     //2 the combination of these are the same as the trunc function   
  25.     high=parseInt(s,10);         
  26.     //3   
  27.     var left=hex[high+1];        
  28.     // left part of the hex-value   
  29.     var low=x-high*16;           
  30.     // calculate the rest of the values   
  31.     s=low+"";                    
  32.     //1   
  33.     s=s.substring(0,2);          
  34.     //2 the combination of these are the same as the trunc function   
  35.     low=parseInt(s,10);          
  36.     //3   
  37.     var right=hex[low+1];        
  38.     // right part of the hex-value   
  39.     var string=left+""+right;    
  40.     // add the high and low together   
  41.     return string;
  42. }
  43.  
  44. function fadein(text){   
  45.     text=text.substring(3,text.length-4);        
  46.     // gets rid of the HTML-comment-tags   
  47.     color_d1=255;                                
  48.     color_d1b=255;
  49.     color_d1c=255;
  50.     // any value in 'begin' 0 to 255   
  51.     mul=color_d1/text.length;   
  52.     for(i=0;i<text.length;i++){      
  53.         color_d1=mul*i; 
  54.         color_d1b=255-mul*i;
  55.         color_d1c=255*Math.sin(i/(text.length/3));
  56.  
  57.         // some other things you can try>> "=255-mul*i" to fade out, "=mul*i" to fade in, or try "255*Math.sin(i/(text.length/3))"      
  58.         color_h1=ToHex(color_d1);      
  59.         color_d2=mul*i;      
  60.         color_h2=ToHex(color_d2);      
  61.         //1b
  62.         color_h1b=ToHex(color_d1b);      
  63.         color_d2b=mul*i;      
  64.         color_h2b=ToHex(color_d2b);      
  65.         //1c
  66.         color_h1c=ToHex(color_d1c);      
  67.         color_d2c=mul*i;      
  68.         color_h2c=ToHex(color_d2c);      
  69.  
  70.         document.write("<FONT COLOR='#FF"+color_h1+color_h2+"'>"+text.substring(i,i+1)+'</FONT>');   
  71.  
  72.     }
  73.     document.write('<p>');
  74.     for(i=0;i<text.length;i++){      
  75.         color_d1=mul*i; 
  76.         color_d1b=255-mul*i;
  77.         color_d1c=255*Math.sin(i/(text.length/3));
  78.  
  79.         // some other things you can try>> "=255-mul*i" to fade out, "=mul*i" to fade in, or try "255*Math.sin(i/(text.length/3))"      
  80.         color_h1=ToHex(color_d1);      
  81.         color_d2=mul*i;      
  82.         color_h2=ToHex(color_d2);      
  83.         //1b
  84.         color_h1b=ToHex(color_d1b);      
  85.         color_d2b=mul*i;      
  86.         color_h2b=ToHex(color_d2b);      
  87.         //1c
  88.         color_h1c=ToHex(color_d1c);      
  89.         color_d2c=mul*i;      
  90.         color_h2c=ToHex(color_d2c);      
  91.  
  92.         document.write("<FONT COLOR='#FF"+color_h1c+color_h2c+"'>"+text.substring(i,i+1)+'</FONT>');   
  93.  
  94.     }
  95.     document.write('<p>');
  96.     for(i=0;i<text.length;i++){      
  97.         color_d1=mul*i; 
  98.         color_d1b=255-mul*i;
  99.         color_d1c=255*Math.sin(i/(text.length/3));
  100.  
  101.         // some other things you can try>> "=255-mul*i" to fade out, "=mul*i" to fade in, or try "255*Math.sin(i/(text.length/3))"      
  102.         color_h1=ToHex(color_d1);      
  103.         color_d2=mul*i;      
  104.         color_h2=ToHex(color_d2);      
  105.         //1b
  106.         color_h1b=ToHex(color_d1b);      
  107.         color_d2b=mul*i;      
  108.         color_h2b=ToHex(color_d2b);      
  109.         //1c
  110.         color_h1c=ToHex(color_d1c);      
  111.         color_d2c=mul*i;      
  112.         color_h2c=ToHex(color_d2c);      
  113.  
  114.         document.write("<FONT COLOR='#FF"+color_h1b+color_h2b+"'>"+text.substring(i,i+1)+'</FONT>');   
  115.  
  116.     }
  117.  
  118. }
  119. // --End Hiding Here -->
  120. </script>
  121. <center><font size=7>Faded Text</font>
  122. <hr width=80%>
  123.  
  124. <SCRIPT LANGUAGE="JavaScript">
  125. <!--   
  126. {
  127.     fadein("-->THIS IS WHERE YOUR TEXT GOES<!__");
  128. }
  129. //-->
  130. </SCRIPT>
  131. </center>
  132.